/**
    {
    "bedtime": "₹879",     //每月还款金额
    "comfort": "₹10,000",     //本金
    "gibbon": "₹550",   //总利息
    "unpacking": "₹10,550",         //总金额
    "zest": [               //还款计划
    {
    "fancy": "03-Dec 2023",   //还款日
    "passing": 1,                  //序号
    "merest": "₹796",    //本金
    "indulgence": "₹83",      //利息
    "reign": "₹9,204"  //剩余本金
    },
    {
    "fancy": "03-Jan 2024",
    "passing": 2,
    "merest": "₹802",
    "indulgence": "₹77",
    "reign": "₹8,402"
    },
    {
    "fancy": "03-Feb 2024",
    "passing": 3,
    "merest": "₹809",
    "indulgence": "₹70",
    "reign": "₹7,593"
    }
    // ...
    ]
    }
 */

/// 计算器主模型
class DnpCalculatorModel {
  /// 每月还款金额
  String? bedtime;
  
  /// 本金
  String? comfort;
  
  /// 总利息
  String? gibbon;
  
  /// 总金额
  String? unpacking;
  
  /// 还款计划列表
  List<DnpCalculatorRepaymentItemModel>? zest;

  DnpCalculatorModel({
    this.bedtime,
    this.comfort,
    this.gibbon,
    this.unpacking,
    this.zest,
  });

  factory DnpCalculatorModel.fromJson(Map<String, dynamic> json) {
    return DnpCalculatorModel(
      bedtime: json['bedtime'] as String?,
      comfort: json['comfort'] as String?,
      gibbon: json['gibbon'] as String?,
      unpacking: json['unpacking'] as String?,
      zest: json['zest'] != null
          ? (json['zest'] as List)
              .map((item) => DnpCalculatorRepaymentItemModel.fromJson(
                  item as Map<String, dynamic>))
              .toList()
          : null,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'bedtime': bedtime,
      'comfort': comfort,
      'gibbon': gibbon,
      'unpacking': unpacking,
      'zest': zest?.map((item) => item.toJson()).toList(),
    };
  }
}

/// 还款计划项模型
class DnpCalculatorRepaymentItemModel {
  /// 还款日
  String? fancy;
  
  /// 序号
  int? passing;
  
  /// 本金
  String? merest;
  
  /// 利息
  String? indulgence;
  
  /// 剩余本金
  String? reign;

  DnpCalculatorRepaymentItemModel({
    this.fancy,
    this.passing,
    this.merest,
    this.indulgence,
    this.reign,
  });

  factory DnpCalculatorRepaymentItemModel.fromJson(Map<String, dynamic> json) {
    return DnpCalculatorRepaymentItemModel(
      fancy: json['fancy'] as String?,
      passing: json['passing'] as int?,
      merest: json['merest'] as String?,
      indulgence: json['indulgence'] as String?,
      reign: json['reign'] as String?,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'fancy': fancy,
      'passing': passing,
      'merest': merest,
      'indulgence': indulgence,
      'reign': reign,
    };
  }
}